package com.cndatacom.teleweb.dao.impl;

import com.cndatacom.teleweb.common.PaginationModel;
import com.cndatacom.teleweb.common.PaginationSupport;
import com.cndatacom.teleweb.dao.IKnowledgeShareDao;
import com.cndatacom.teleweb.model.KnowledgeShare;

public class KnowledgeShareDao extends PaginationSupport implements IKnowledgeShareDao {

	public KnowledgeShare addKnowledgeShare(KnowledgeShare knowledgeShare) {
		getHibernateTemplate().save(knowledgeShare);
		return knowledgeShare;
	}

	public boolean delKnowledgeShare(KnowledgeShare knowledgeShare) {
		getHibernateTemplate().delete(knowledgeShare);
		return true;
	}

	public PaginationModel getAllKnowledgeShare(int offset, int pageSize) {
		return searchPaginated("select ks from com.cndatacom.teleweb.model.KnowledgeShare ks where uploadDate <= current_timestamp() order by ks.uploadDate desc", offset, pageSize);
	}

	public KnowledgeShare getKnowledgeShareById(int KnowledgeId) {
		return (KnowledgeShare)getHibernateTemplate().get(KnowledgeShare.class, KnowledgeId);
	}

	public KnowledgeShare updateKnowledgeShare(KnowledgeShare knowledgeShare) {
		getHibernateTemplate().update(knowledgeShare);
		return knowledgeShare;
	}

	public KnowledgeShare saveOrUpdateKnowledgeShare(KnowledgeShare knowledgeShare) {
		getHibernateTemplate().saveOrUpdate(knowledgeShare);
		return knowledgeShare;
		
	}

}
